<!-- 
@name:YwRuleUpd.vue 
@description: 积分业务规则弹窗
@author: crj
@date: 2020/09/08
-->
<template>
	<el-dialog :title="'选择地址'" :visible.sync="visible" :modal='false'>
		<div>
			<iframe id="mapPage" width="100%" height="800" frameborder=0 src="https://apis.map.qq.com/tools/locpicker?search=1&type=1&key=5LQBZ-THC67-VJOXM-PAUAY-FZLJQ-PSB32&referer=myapp">
			</iframe>
		</div>
		<div slot="footer" class="dialog-footer">
			<el-button size="medium" @click="hide"> 取 消 </el-button>
			<el-button size="medium" type="primary" @click="handleSubmit" :loading="loading">
				确 定
			</el-button>
		</div>
	</el-dialog>
</template>

<script>
export default {
	props: {
		title: '',
	},
	data() {
		return {
			labelWidth: '120px',
			visible: !1,
			loading: !1,
			inputModel: {},
			vendorList: [],
			vipEnabled: true,
			hdEnabled: true,
			typeList: [
				{
					pkey: 'COUNT',
					name: '按业务笔数',
				},
				{
					pkey: 'AMT',
					name: '按业务金额(元)',
				},
				// {
				//   pkey: "SALE",
				//   name: "积分消费"
				// },
				// {
				//   pkey: "MANUAL",
				//   name: "人工调整"
				// },
			],
		};
	},
	mounted() {
		var that = this;
		window.addEventListener(
			'message',
			function (event) {
				// 接收位置信息，用户选择确认位置点后选点组件会触发该事件，回传用户的位置信息
				var loc = event.data;
				if (loc && loc.module == 'locationPicker') {
					//防止其他应用也会向该页面post信息，需判断module是否为'locationPicker'
					console.log('location', loc);
					that.inputModel = loc;
				}
			},
			false
		);
	},
	methods: {
		dropList_vendor() {
			var params = {
				pagesize: 9999,
			};
			this.$myApi.dropList_vendor(params).then((res) => {
				if (res.code == 0) {
					this.vendorList = res.result.content;
				}
			});
		},
		/**
		 * 图片删除事件
		 */
		delImg: function (name, secondName) {
			if (!secondName) {
				this.inputModel[name] = [];
			} else {
				this.inputModel[secondName][name] = [];
			}
		},
		/**
		 * 图片修改事件
		 */
		changeImg: function (imgUrl, name, secondName) {
			console.log(imgUrl, name);
			var urlList = [];
			imgUrl.map((item) => {
				urlList.push({ url: item });
			});
			if (!secondName) {
				this.inputModel[name] = urlList;
			} else {
				this.inputModel[secondName][name] = urlList;
			}
		},
		/**
		 * 清空数据
		 */
		clearData: function () {
			this.inputModel = {};
		},
		/**
		 * 初始化数据
		 */
		initData: function ({ inputModel }) {
			console.log(inputModel);
			this.inputModel = inputModel;
			this.hdEnabled = inputModel.hdEnabled;
			this.vipEnabled = inputModel.vipEnabled;
		},
		show: function () {
			this.visible = true;
			this.clearData();
		},
		/**
		 * 提交
		 */
		handleSubmit() {
			var inputModel = JSON.parse(JSON.stringify(this.inputModel));
			this.$emit('confirm', {
				inputModel: inputModel,
			});
			this.hide();
		},
		/**
		 * 取消
		 */
		hide() {
			this.clearData();
			this.visible = !1;
			this.$emit('hide');
		},
	},
};
</script>

<style  scoped>
</style>

